﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Web.Script.Serialization;
using System.IO;

namespace WebBHXH.Entities
{


    class DonViBHModel
    {
        public DonViBHModel()
        {
        }

        public DonViBHModel(string json)
        {
            JObject jObject = JObject.Parse(json);
            maDonViBH = (string)jObject["Ma_DonViBH"];
            tenDonViBH = (string)jObject["Ten_DonViBH"];
            diaChi = (string)jObject["DiaChi"];
            dienThoai = (string)jObject["DienThoai"];
            email = (string)jObject["Email"];
            ghiChu = (string)jObject["GhiChu"];
        }

        public List<DonViBHModel> GetDonViBHModel()
        {
            System.Net.WebRequest request = System.Net.WebRequest.Create("" + Util.getUrl() + "Home/GetDonViBHModel");

            request.Method = "POST";
            request.ContentLength = 0;
            request.ContentType = "application/json; charset=utf-8";
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            //get response-stream, and use a streamReader to read the content
            List<DonViBHModel> listDonViBHModel = new List<DonViBHModel>();
            using (Stream s = request.GetResponse().GetResponseStream())
            {
                using (StreamReader sr = new StreamReader(s))
                {
                    JavaScriptSerializer jsonserializer = new JavaScriptSerializer();
                    listDonViBHModel = jsonserializer.Deserialize<List<DonViBHModel>>(sr.ReadToEnd());
                    return listDonViBHModel;
                }
            }

            return new List<DonViBHModel>();
        }

        private string maDonViBH;

        public string MaDonViBH
        {
            get { return maDonViBH; }
            set { maDonViBH = value; }
        }
        private string tenDonViBH;

        public string TenDonViBH
        {
            get { return tenDonViBH; }
            set { tenDonViBH = value; }
        }
        private string diaChi;

        public string DiaChi
        {
            get { return diaChi; }
            set { diaChi = value; }
        }
        private string dienThoai;

        public string DienThoai
        {
            get { return dienThoai; }
            set { dienThoai = value; }
        }
        private string email;

        public string Email
        {
            get { return email; }
            set { email = value; }
        }
        private string ghiChu;

        public string GhiChu
        {
            get { return ghiChu; }
            set { ghiChu = value; }
        }

    }
}
